import { InternalAxiosRequestConfig } from 'axios';
import { useAuthStore } from '@/stores/auth';

export default function (
  request: InternalAxiosRequestConfig
): InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig> {
  const token = useAuthStore.getState().userInfo.token;

  if (token) {
    request.data = { ...request.data, token };
  }

  return request;
}
